
package edu.tongji.jiaowu.dao.jdbc;
 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import edu.tongji.jiaowu.dao.EvtStudentResultDao;
import com.tongji.quickCRUDQ.define.Row;
import com.tongji.quickCRUDQ.model.CommonBean;
import com.tongji.quickCRUDQ.dao.jdbc.BaseDaoJdbc;

public class EvtStudentResultDaoJdbc extends BaseDaoJdbc implements EvtStudentResultDao {
	String tableName="T_EVT_STUDENT_RESULT";
	String beanName="evtStudentResult";
	
	public CommonBean createEvtStudentResult(){
		CommonBean evtStudentResults=this.createBean(tableName,beanName);
                return evtStudentResults;		
	}
	
/*
	public CommonBean findEvtStudentResults(String refid) {
		CommonBean evtStudentResults=this.createEvtStudentResult();
		String sql="select * from T_EVT_STUDENT_RESULT where refid=?";
		List data=this.getCommonDao().select(sql,new String[]{refid});
		evtStudentResults.addData(data);
                return evtStudentResults;
       }
*/
	public CommonBean findEvtStudentResultById(String id) {
		CommonBean evtStudentResults=this.createEvtStudentResult();
		String sql="select * from T_EVT_STUDENT_RESULT where id=?";
		List data=this.getCommonDao().select(sql,new String[]{id});
		evtStudentResults.addData(data);
    return evtStudentResults;
  }
  
	public CommonBean findAllEvtStudentResults() {
		CommonBean evtStudentResults=this.createEvtStudentResult();
		String sql="select * from T_EVT_STUDENT_RESULT ";
		List data=this.getCommonDao().select(sql,new String[]{});
		evtStudentResults.addData(data);
    return evtStudentResults;
  }
	public void insertEvtStudentResult(CommonBean evtStudentResultBean){
		List data=evtStudentResultBean.getData();
		Row row=this.getRow(tableName);
		this.getCommonDao().templateBatchInsert(row,data,this.getIdGenerator());
	}
	public void updateEvtStudentResult(CommonBean evtStudentResultBean){
		List data=evtStudentResultBean.getData();
		Row row=this.getRow(tableName);
		this.getCommonDao().templateBatchUpdate(row,data);
	}

	public void finish(Map map, String refid) {
		String sql="insert into T_EVT_STUDENT_RESULT(id,refid,question_no,result) values(dbo.get_seq(),?,?,?)";
		List paramList=new ArrayList();
		Iterator keys=map.keySet().iterator();
		while (keys.hasNext()) {
			String questionNo= (String) keys.next();
			String result=(String) map.get(questionNo);
			String params[]=new String[]{refid,questionNo,result};
			paramList.add(params);
		}
		getCommonDao().batchUpdateRecord(sql, paramList);
	}

}

